package com.iam.controller;

import com.iam.util.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * create by yongli on 2021-05-10 17:18
 * 请求错误处理
 */
@ControllerAdvice
public class ErrorHandlerController {

    // 这个参数是怎么传入的？,ResponseBody很重要
    @ResponseBody
    @ExceptionHandler(Exception.class)
    public CommonResult handler(Exception e) {
        return CommonResult.failure(e.getMessage());
    }
}
